<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                xmlns:security="http://www.springframework.org/security/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">首页模块</ui:define>
    <ui:define name="content">
        <h:form>
            <p:dialog header="执行操作中,请稍后" widgetVar="doing" modal="true" closable="false" resizable="false"
                      draggable="false"/>
            <p:defaultCommand target="search"/>
            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton id="search" value="查询" icon="fa fa-search"
                                         update="@form"
                                         rendered="#{loanPageTemplateListBean.isNormal()}"/>
                        <p:commandButton value="重置" icon="fa fa-refresh"
                                         actionListener="#{loanPageTemplateListBean.onReset}"
                                         process="@this"
                                         update="@form"
                                         rendered="#{loanPageTemplateListBean.isNormal()}"/>
                        <p:commandButton icon="fa fa-plus" value="新增"
                                         action="#{loanPageTemplateListBean.onAdd}"
                                         rendered="#{loanPageTemplateListBean.isNormal()}">
                            <f:setPropertyActionListener value="/views/pageTemplate/list.xhtml"
                                                         target="#{currentUserBean.back}"/>
                        </p:commandButton>
                    </f:facet>
                </p:toolbar>
            </div>
            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card">
                            <h1>查询条件</h1>
                            <p:panelGrid columns="4" layout="grid"
                                         columnClasses="ui-grid-col-1,ui-grid-col-5,ui-grid-col-1,ui-grid-col-5"
                                         styleClass="ui-panelgrid-blank"
                                         style="border:0px none; background-color:transparent;">

                                <p:outputLabel for="name" value="首页模板名称"/>
                                <p:inputText id="name" value="#{loanPageTemplateListBean.$.name}"/>

                                <p:outputLabel for="parentId" value="大产品"/>
                                <p:selectOneMenu id="parentId" value="#{loanPageTemplateListBean.$.parentId}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                                  noSelectionOption="true"/>
                                    <f:selectItems value="#{loanPageTemplateListBean.dictionaries[DictionaryCode.LARGE_COMMON_PRODUCT]}"
                                                   var="dic"
                                                   itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                    <p:ajax event="change" process="@this" update="products" listener="#{loanPageTemplateListBean.onSelectParentProd}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="products" value="适用产品"/>
                                <p:selectOneMenu id="products" value="#{loanPageTemplateListBean.$.productId}" filter="true">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                                  noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{loanPageTemplateListBean.commProductIds}"
                                            var="dic" itemLabel="#{dic.name}" itemValue="#{dic.productId}"/>
                                </p:selectOneMenu>

                                <p:outputLabel for="status" value="状态"/>
                                <p:selectOneMenu id="status" value="#{loanPageTemplateListBean.$.status}">
                                    <f:selectItem itemLabel="- 请选择 -" itemValue=""
                                                  noSelectionOption="true"/>
                                    <f:selectItems
                                            value="#{loanPageTemplateListBean.dictionaries[DictionaryCode.ONLINE_OFFLINE_STATUS]}"
                                            var="dic"
                                            itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                </p:selectOneMenu>
                            </p:panelGrid>
                        </div>
                        <div class="card">
                            <p:dataTable id="pageTemplateInfoDataTable"
                                         style="width: 100%"
                                         var="pageTemplateInfo"
                                         value="#{loanPageTemplateListBean.lazyDataModel}"
                                         rows="#{constants:get('ROWS')}"
                                         lazy="true"
                                         paginator="true"
                                         paginatorTemplate="#{constants:get('PAGINATOR_TEMPLATE')}"
                                         rowsPerPageTemplate="#{constants:get('ROWS_PER_PAGE_TEMPLATE')}"
                                         emptyMessage="#{constants:get('EMPTY_MESSAGE')}"
                                         scrollable="true"
                                         scrollWidth="97%"
                                         reflow="true"
                                         selection="#{loanPageTemplateListBean.selectedRecords}"
                                         resizableColumns="true"
                                         rendered="#{security:areAllGranted('LOAN_FAMILY_TAGS_FIRST_PARTY_SEARCH')}">


                                <p:column headerText="操作" rendered="#{loanPageTemplateListBean.isNotBatch()}">
                                    <p:splitButton icon="fa fa-eye"
                                                   action="#{loanPageTemplateListBean.onEdit(pageTemplateInfo.id)}"
                                                   process="@this">
                                        <f:setPropertyActionListener
                                                value="/views/pageTemplate/list.xhtml"
                                                target="#{currentUserBean.back}"/>
                                        <p:menuitem value="上线" icon="fa fa-arrow-up"
                                                    actionListener="#{loanPageTemplateListBean.online(pageTemplateInfo.id)}"
                                                    onstart="PF('doing').show()"
                                                    process="@this" update="@form"
                                                    rendered="#{pageTemplateInfo.status == 0}"/>

                                        <p:menuitem value="下线" icon="fa fa-arrow-down"
                                                    actionListener="#{loanPageTemplateListBean.offline(pageTemplateInfo.id)}"
                                                    onstart="PF('doing').show()"
                                                    process="@this" update="@form"
                                                    rendered="#{pageTemplateInfo.status == 1 }"/>

                                        <p:menuitem value="删除" icon="fa fa-fw fa-remove"
                                                    actionListener="#{loanPageTemplateListBean.onDelete(pageTemplateInfo.id)}"
                                                    process="@this" update="@form">
                                            <p:confirm header="提示信息" message="是否确定删除?" icon="ui-icon-alert"/>
                                        </p:menuitem>
                                    </p:splitButton>
                                </p:column>
                                <p:column selectionMode="multiple" style="width:16px;text-align:center"
                                          rendered="#{loanPageTemplateListBean.isBatch()}"/>
                                <p:column headerText="状态" style="text-align: center">
                                    <h:outputText style="font-weight: bold; color: red" value="已下线" rendered="#{pageTemplateInfo.status == 0}"/>
                                    <h:outputText style="font-weight: bold; color: green" value="上线中" rendered="#{pageTemplateInfo.status == 1}"/>
                                </p:column>
                                <p:column headerText="首页模板名称" style="text-align: center">
                                    <h:outputText value="#{pageTemplateInfo.name}"/>
                                </p:column>
                                <p:column headerText="大产品" style="text-align: center">
                                    <h:outputText value="#{pageTemplateInfo.parentName}"/>
                                </p:column>
                                <p:column headerText="适用产品" style="text-align: center">
                                    <h:outputText value="#{pageTemplateInfo.products}"/>
                                </p:column>
                                <p:column headerText="最后更新人" style="text-align: center">
                                    <h:outputText value="#{pageTemplateInfo.updator}"/>
                                </p:column>
                                <p:column headerText="更新时间" style="text-align: center">
                                    <h:outputText value="#{pageTemplateInfo.updateTime}"/>
                                </p:column>
                                <p:column headerText="创建时间" style="text-align: center">
                                    <h:outputText value="#{pageTemplateInfo.createTime}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
